package vsy.buzzwordbingo.client;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;

public class WinnerWindow {
	
	private JPanel jPanel1 = null;  
	private JPanel jPanel = null;  
	private JFrame TitleWindow = null;  
    private JLabel nameLabel = null;
    private JFrame WinnerWindow = null;
    private JButton button = null;
		
	/**
	 * This method initializes TitleWindow	
	 * 	
	 * @return javax.swing.JFrame	
	 */
	public JFrame getWinnerWindow(String winner) {
		
			WinnerWindow = new JFrame();
			WinnerWindow.setSize(new Dimension(800, 640));
			WinnerWindow.setLocationRelativeTo(null);
			WinnerWindow.setResizable(false);
			WinnerWindow.setContentPane(getJPanel1(winner));
			WinnerWindow.setTitle("Buzzword Bingo");
			WinnerWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		return WinnerWindow;
	}
	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel1(String winner) {
		if (jPanel1 == null) {
			jPanel1 = new BackGroundPane("src/main/images/buzzwordbingo_winner_bg.jpg");
			jPanel1.setLayout(null);
			nameLabel = new JLabel();
			nameLabel.setBounds(new Rectangle(300, 420, 200, 100));
			nameLabel.setText("Du hast gewonnen!");
			jPanel1.add(nameLabel, null);
			jPanel1.add(getbutton());
		}
		return jPanel1;
	}
	private JButton getbutton() {
		if (button == null) {
			button = new JButton();
			button.setLocation(315,500);
			button.setText("Lobby");
			button.setSize(new Dimension(74, 16));
			button.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					WinnerWindow.setVisible(false);
					WinnerWindow.dispose();
				}});
			}
		return button;
	}
}
